import random

def guess_number():
    secert_number =  random.randint(1,100)
    attemp = 0

    while True:
        try:
            guess = int(input("请输入你猜的数字："))
            attemp += 1
            if guess < secert_number:
                print("猜小了")
            elif guess > secert_number:
                print("猜大了")
            else:
                print(f"猜对了，你只用了{attemp}次就猜对了")
                break
        except ValueError:
            print("输入有误，请重新输入")
guess_number()



